<template>
    <div class="all">
        <div class="bread">首页>>财务管理>>订单管理</div>
        <div class="nav">
            <div>
                <el-button  type="primary"  plain @click="dialogVisible = true">添加订单</el-button> 
                <span>发布时间</span>
                <span>车型：    
                     <el-select v-model="value" placeholder="选择车型" style="width: 240px">
                       <el-option
                         v-for="item in options"
                         :key="item.value"
                         :label="item.label"
                         :value="item.value"
                       />
                     </el-select>
                </span>
                <span>关键字<input></span>
                <span>搜索</span>
            </div>
        </div>
        <div class="content">
            <el-table :data="tableData" style="width: 100%">
              <el-table-column fixed prop="xuhao" label="序号" width="60"/>
              <el-table-column prop="xiangmu" label="项目名称" width="100" />
              <el-table-column prop="dingdanhao" label="订单号" width="100" />
              <el-table-column prop="riqi" label="日期" width="100" />
              <el-table-column prop="chepaihao" label="车牌号" width="120" />
              <el-table-column prop="chexing" label="车型" width="120" />
              <el-table-column prop="leixing" label="类型" width="100" />
              <el-table-column prop="jine" label="金额" width="100" />
              <el-table-column prop="kehu" label="客户姓名" width="100" />
              <el-table-column prop="dianhua" label="电话" width="100" />
              <el-table-column prop="siji" label="司机" width="100" />
              <el-table-column prop="jiedan" label="结单" width="120" >
                <template #default>
                  <el-button link type="primary" size="small">结算</el-button>
                </template>
              </el-table-column>
              <!-- <el-table-column prop="zhuangtai" label="选择车辆" width="100" /> -->
              <!-- <el-table-column prop="waidiao" label="快捷操作" width="100" /> -->
              <!-- <el-table-column prop="address" label="Address" width="600" /> -->
              <!-- <el-table-column prop="zip" label="Zip" width="120" /> -->
              <el-table-column fixed="right" label="操作" width="120">
                <template #default="scope" >
                  <el-button link type="primary" size="small" @click.prevent="bianjiClick(scope.$index, tableData)"
                    >编辑</el-button>
                  <el-button link type="primary" size="small">删除</el-button>
                </template>
              </el-table-column>
            </el-table>

        </div>
    </div>

    <!-- 添加记录对话框 -->
     <el-dialog
         v-model="dialogVisible"
         title="添加订单"
         width="500"
         :before-close="handleClose"
         style="text-align:center;padding-top: 10px;"
       >
       <!-- 添加记录的表单内容 -->
        <el-form :model="form" label-width="auto" style="max-width: 800px;padding: 0px 40px 40px 40px;">
          <el-form-item inline-message='true' label="车辆类型">
            <el-select v-model="form.chexing" placeholder="选择车辆类型">
              <el-option label="车型1" value="车型1" />
              <el-option label="车型2" value="车型2" />
            </el-select>
          </el-form-item>
          <el-form-item label="车牌号码">
            <el-input v-model="form.carNum" />
          </el-form-item>
          <el-form-item label="车辆名称">
            <el-input v-model="form.carname" />
          </el-form-item>
          <el-form-item label="上牌时间">
            <el-col :span="11">
              <el-date-picker
                v-model="form.shangdate"
                type="date"
                placeholder="选择时间"
                style="width: 100%"
              />
            </el-col>
          </el-form-item>
         <el-form-item label="型号">
            <el-select v-model="form.xinghao" placeholder="选择型号">
              <el-option label="型号a" value="型号a" />
              <el-option label="型号b" value="型号b" />
            </el-select>
          </el-form-item>
          <el-form-item label="车架号">
            <el-input v-model="form.chejiahao" />
          </el-form-item>
          <el-form-item label="发动机号">
            <el-input v-model="form.fadongjihao" />
          </el-form-item>
         <el-form-item label="行驶里程">
            <el-input v-model="form.licheng" />
          </el-form-item>
         <el-form-item label="所处位置">
            <el-input v-model="form.position" />
          </el-form-item>

         <el-form-item label="首次年检日期">
            <el-col :span="11">
              <el-date-picker
                v-model="form.shoucinianjian"
                type="date"
                placeholder="选择时间"
                style="width: 100%"
              />
            </el-col>
          </el-form-item>
          <el-form-item label="状态">
            <el-select v-model="form.zhuangtai" placeholder="选择状态">
              <el-option label="使用" value="使用" />
              <el-option label="闲置" value="闲置" />
            </el-select>
          </el-form-item>
        <el-form-item label="外调">
            <el-select v-model="form.waidiao" placeholder="选择记录类型">
              <el-option label="是" value="是" />
              <el-option label="否" value="否" />
            </el-select>
          </el-form-item>

        </el-form>

         <template #footer>
           <div class="dialog-footer">
             <el-button @click="dialogVisible = false">取消</el-button>
             <el-button type="primary" @click="dialogVisible = false">
               确认
             </el-button>
           </div>
         </template>
     </el-dialog>
       

    <!-- 编辑记录对话框 -->
     <el-dialog
         v-model="bianjiVisible"
         title="编辑车辆信息"
         width="500"
         :before-close="handleClose"
         style="text-align:center;padding-top: 10px;"
       >
       <!-- 编辑记录的表单内容 -->
        <el-form :model="form1" label-width="auto" style="max-width: 800px;padding: 0px 40px 40px 40px;">
          <el-form-item inline-message='true' label="车辆类型">
            <el-select v-model="form1.type" placeholder="选择车辆类型">
              <el-option label="车型1" value="车型1" />
              <el-option label="车型2" value="车型2" />
            </el-select>
          </el-form-item>
          <el-form-item label="车牌号码">
            <el-input v-model="form1.chepaihao" />
          </el-form-item>
          <el-form-item label="车辆名称">
            <el-input v-model="form1.name" />
          </el-form-item>
          <el-form-item label="上牌时间">
            <el-col :span="11">
              <el-date-picker
                v-model="form1.date"
                type="date"
                placeholder="选择时间"
                style="width: 100%"
              />
            </el-col>
          </el-form-item>
         <el-form-item label="型号">
            <el-select v-model="form1.xinghao" placeholder="选择型号">
              <el-option label="型号a" value="型号a" />
              <el-option label="型号b" value="型号b" />
            </el-select>
          </el-form-item>
          <el-form-item label="车架号">
            <el-input v-model="form1.chejia" />
          </el-form-item>
          <el-form-item label="发动机号">
            <el-input v-model="form1.fadongji" />
          </el-form-item>
         <el-form-item label="行驶里程">
            <el-input v-model="form1.licheng" />
          </el-form-item>
         <el-form-item label="所处位置">
            <el-input v-model="form1.position" />
          </el-form-item>

         <el-form-item label="首次年检日期">
            <el-col :span="11">
              <el-date-picker
                v-model="form1.nianjian"
                type="date"
                placeholder="选择时间"
                style="width: 100%"
              />
            </el-col>
          </el-form-item>
          <el-form-item label="状态">
            <el-select v-model="form1.zhuangtai" placeholder="选择状态">
              <el-option label="使用" value="使用" />
              <el-option label="闲置" value="闲置" />
            </el-select>
          </el-form-item>
        <el-form-item label="外调">
            <el-select v-model="form1.waidiao" placeholder="选择记录类型">
              <el-option label="是" value="是" />
              <el-option label="否" value="否" />
            </el-select>
          </el-form-item>

        </el-form>

         <template #footer>
           <div class="dialog-footer">
             <el-button @click="bianjiVisible = false">取消</el-button>
             <el-button type="primary" @click="bianjiVisible = false">
               确认
             </el-button>
           </div>
         </template>
     </el-dialog>       
</template>

<script setup>
import { ref, reactive } from 'vue'

//添加记录对话框开关
const dialogVisible = ref(false)
//编辑记录对话框开关
const bianjiVisible = ref(false)

const value = ref('')

//车型选择
const options = [
    {
        value: '防撞车',
        label: '防撞车',
    },
    {
        value: '高空作业车',
        label: '高空作业车',
    },
    {
        value: '桥梁检测车',
        label: '桥梁检测车',
    },
    {
        value: '自行走',
        label: '自行走',
    }
]
//表格 标题和内容
const tableData = [
    {
        xuhao: '01',
        xiangmu: '高速公路',
        dingdanhao: '订单001',
        riqi: '2022-10-01',
        chepaihao: '京a001',
        chexing: '70k防撞车',
        leixing: '月租',
        jine: '13000',
        kehu: '王经理',
        siji: '司机a',
        dianhua: '18866668888',
        name: '6米自行走',
        date: '2022-10-01',
        xinghao: '型号b',
        chejia: '车架号0001',
        fadongji: '发动机号0001',
        licheng: '6666',
        position: '北京',
        nianjian: '2023-10-01',
        zhuangtai: '使用',
        waidiao: '否'
    }
]
// 添加记录的表单内容
const form = reactive({
    type: '',
    chepaihao: '',
    name: '',
    date: '',
    xinghao: '',
    chejia: '',
    fadongji: '',
    licheng: '',
    position: '',
    nianjian: '',
    zhuangtai: '',
    waidiao: '',
})

// 编辑记录的表单内容
const form1 = ref({
    xuhao: '',
    type: '',
    chepaihao: '',
    name: '',
    date: '',
    xinghao: '',
    chejia: '',
    fadongji: '',
    licheng: '',
    position: '',
    nianjian: '',
    zhuangtai: '',
    waidiao: ''
},)

// 编辑车辆记录按钮
const bianjiClick = (index, data) => {

    console.log(tableData, 'xuhao')
    console.log(index)
    console.log(tableData[index])
    form1.value = tableData[index]
    console.log(form1.value)
    bianjiVisible.value = true
}

const deleteRow = (index) => {
    console.log(index)
}

</script>

<style lang="scss" scoped>
.all {
    background-color: #d6d6d6;
    height: 100%;
    overflow: hidden;
    padding-left: 10px;

    .bread {
        height: 30px;
        background-color: #fff;
        margin-bottom: 10px;
    }

    .nav {
        height: 40px;
        background-color: #fff;
        margin-bottom: 10px;
        padding: 5px;

        div {
            span {
                margin: 10px;
                line-height: 40px;
            }
        }
    }

    .content {
        background: #fff;
        height: 100%;
        padding: 5px;
        overflow: hidden;
    }
}</style>